﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace FacialClub.Helpers
{
    /// <summary>
    /// HttpCookieCollectionExtensions
    /// </summary>
    public static class HttpCookieCollectionExtensions
    {
        private const string ANONYMOUS_USER_COOKIE_NAME = "anon";

        /// <summary>
        /// Clear Anonymous User
        /// </summary>
        /// <param name="cookies"></param>
        public static void ClearAnonymousUser(this HttpCookieCollection cookies)
        {
            cookies.Add(new HttpCookie(ANONYMOUS_USER_COOKIE_NAME) { Expires = DateTime.Now.AddDays(-1) });
        }

        //public static UserBase GetAnonymousUser(this HttpCookieCollection cookies)
        //{
        //    UserBase user = null;

        //    HttpCookie cookie = cookies[ANONYMOUS_USER_COOKIE_NAME];
        //    if (cookie != null)
        //    {
        //        user = user.FillFromSerlializedString(cookie.Value);
        //    }

        //    return user;
        //}

        //public static void SetAnonymousUser(this HttpCookieCollection cookies, UserBase user)
        //{
        //    HttpCookie cookie = new HttpCookie(ANONYMOUS_USER_COOKIE_NAME, user.ToJson());
        //    cookie.Expires = DateTime.Now.AddDays(14);

        //    cookies.Add(cookie);
        //}
    }
}